package com.eastfair.messagecenter.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.eastfair.core.base.entity.Entity;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.messagecenter.enumeration.MsgContentType;
import com.eastfair.messagecenter.enumeration.SendStatus;
import com.eastfair.messagecenter.enumeration.MsgType;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 消息表
 * </p>
 *
 * @author ligang
 * @since 2023-04-21
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("e_msg")
@ApiModel(value = "Msg", description = "消息表")
@AllArgsConstructor
public class Msg extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 业务id
     */
    @ApiModelProperty(value = "业务id")
    @Size(max = 255, message = "业务id长度不能超过255")
    @TableField(value = "business_id", condition = LIKE)
    @Excel(name = "业务id")
    private String businessId;

    /**
     * 业务类型，由业务方自己定
     */
    @ApiModelProperty(value = "业务类型，由业务方自己定")
    @Size(max = 64, message = "业务类型，由业务方自己定长度不能超过64")
    @TableField(value = "business_type", condition = LIKE)
    @Excel(name = "业务类型，由业务方自己定")
    private String businessType;

    /**
     * 消息类型 
     * #MsgType{WAIT:待办;NOTIFY:通知;PUBLICITY:公告;WARN:预警;}
     */
    @ApiModelProperty(value = "消息类型")
    @NotNull(message = "请填写消息类型")
    @TableField(value = "msg_type")
    @Excel(name = "消息类型", replace = {"待办_WAIT", "通知_NOTIFY", "公告_PUBLICITY", "预警_WARN",  "_null"})
    private MsgType msgType;

    /**
     * 消息内容类型 
     * #MsgContentType{SYSTEM:系统消息;BUSINESS:业务消息;OPERATION:运营消息;}
     */
    @ApiModelProperty(value = "消息内容类型")
    @NotNull(message = "请填写消息内容类型")
    @TableField(value = "msg_content_type")
    @Excel(name = "消息内容类型", replace = {"系统消息_SYSTEM", "业务消息_BUSINESS", "运营消息_OPERATION",  "_null"})
    private MsgContentType msgContentType;

    /**
     * 标题
     */
    @ApiModelProperty(value = "标题")
    @Size(max = 255, message = "标题长度不能超过255")
    @TableField(value = "title", condition = LIKE)
    @Excel(name = "标题")
    private String title;

    /**
     * 内容
     */
    @ApiModelProperty(value = "内容")
    @Size(max = 255, message = "内容长度不能超过255")
    @TableField(value = "content", condition = LIKE)
    @Excel(name = "内容")
    private String content;

    /**
     * 发布人
     */
    @ApiModelProperty(value = "发布人")
    @Size(max = 32, message = "发布人长度不能超过32")
    @TableField(value = "author", condition = LIKE)
    @Excel(name = "发布人")
    private String author;

    /**
     * 手机号
     */
    @ApiModelProperty(value = "手机号")
    @Size(max = 255, message = "手机号长度不能超过255")
    @TableField(value = "mobile", condition = LIKE)
    @Excel(name = "手机号")
    private String mobile;

    /**
     * 接收人用户id
     */
    @ApiModelProperty(value = "接收人用户id")
    @TableField(value = "user_id")
    @Excel(name = "接收人用户id")
    private Long userId;

    /**
     * 处理地址 以http开头时直接跳转，否则与#c_application表拼接后跳转http可带参数
     */
    @ApiModelProperty(value = "处理地址 以http开头时直接跳转，否则与#c_application表拼接后跳转http可带参数")
    @Size(max = 255, message = "处理地址 以http开头时直接跳转，否则与#c_application表拼接后跳转http可带参数长度不能超过255")
    @TableField(value = "handler_url", condition = LIKE)
    @Excel(name = "处理地址 以http开头时直接跳转，否则与#c_application表拼接后跳转http可带参数")
    private String handlerUrl;

    /**
     * 处理参数
     */
    @ApiModelProperty(value = "处理参数")
    @Size(max = 500, message = "处理参数长度不能超过500")
    @TableField(value = "handler_params", condition = LIKE)
    @Excel(name = "处理参数")
    private String handlerParams;

    /**
     * 是否发送给全体人员(默认1：是 0:否)
     */
    @ApiModelProperty(value = "是否发送给全体人员(默认1：是 0:否)")
    @TableField(value = "is_send_user_all")
    @Excel(name = "是否发送给全体人员(默认1：是 0:否)")
    private Integer isSendUserAll;

    /**
     * 短信模板id
     */
    @ApiModelProperty(value = "短信模板id")
    @TableField(value = "note_template_id")
    @Excel(name = "短信模板id")
    private Long noteTemplateId;

    /**
     * 邮箱模板id
     */
    @ApiModelProperty(value = "邮箱模板id")
    @TableField(value = "email_template_id")
    @Excel(name = "邮箱模板id")
    private Long emailTemplateId;

    /**
     * 站内信模板id
     */
    @ApiModelProperty(value = "站内信模板id")
    @TableField(value = "inner_msg_template_id")
    @Excel(name = "站内信模板id")
    private Long innerMsgTemplateId;

    /**
     * 是否短信发送(默认1：是 0:否)
     */
    @ApiModelProperty(value = "是否短信发送(默认1：是 0:否)")
    @TableField(value = "is_note_send")
    @Excel(name = "是否短信发送(默认1：是 0:否)")
    private Integer isNoteSend;

    /**
     * 是否邮箱发送(默认1：是 0:否)
     */
    @ApiModelProperty(value = "是否邮箱发送(默认1：是 0:否)")
    @TableField(value = "is_email_send")
    @Excel(name = "是否邮箱发送(默认1：是 0:否)")
    private Integer isEmailSend;

    /**
     * 是否站内信发送(默认1：是 0:否)
     */
    @ApiModelProperty(value = "是否站内信发送(默认1：是 0:否)")
    @TableField(value = "is_inner_msg_send")
    @Excel(name = "是否站内信发送(默认1：是 0:否)")
    private Integer isInnerMsgSend;

    /**
     * 短信是否发送成功(默认1：是 0:否)
     */
    @ApiModelProperty(value = "短信是否发送成功(默认1：是 0:否)")
    @TableField(value = "is_note_send_succ")
    @Excel(name = "短信是否发送成功(默认1：是 0:否)")
    private Integer isNoteSendSucc;

    /**
     * 邮箱是否发送成功(默认1：是 0:否)
     */
    @ApiModelProperty(value = "邮箱是否发送成功(默认1：是 0:否)")
    @TableField(value = "is_email_send_succ")
    @Excel(name = "邮箱是否发送成功(默认1：是 0:否)")
    private Integer isEmailSendSucc;

    /**
     * 站内信是否发送成功(默认1：是 0:否)
     */
    @ApiModelProperty(value = "站内信是否发送成功(默认1：是 0:否)")
    @TableField(value = "is_inner_msg_send_succ")
    @Excel(name = "站内信是否发送成功(默认1：是 0:否)")
    private Integer isInnerMsgSendSucc;

    /**
     * 是否立即发送 1是 0否
     */
    @ApiModelProperty(value = "是否立即发送 1是 0否")
    @TableField(value = "is_send_now")
    @Excel(name = "是否立即发送 1是 0否")
    private Integer isSendNow;

    /**
     * 预计发送时间
     */
    @ApiModelProperty(value = "预计发送时间")
    @TableField(value = "predict_send_time")
    @Excel(name = "预计发送时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime predictSendTime;

    /**
     * 发送时间
     */
    @ApiModelProperty(value = "发送时间")
    @TableField(value = "send_time")
    @Excel(name = "发送时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime sendTime;

    /**
     * 是否已读
     */
    @ApiModelProperty(value = "是否已读")
    @TableField(value = "is_read")
    @Excel(name = "是否已读")
    private Integer isRead;

    /**
     * 邮箱发送结果
     */
    @ApiModelProperty(value = "邮箱发送结果")
    @Size(max = 1599, message = "邮箱发送结果长度不能超过1599")
    @TableField(value = "email_send_result", condition = LIKE)
    @Excel(name = "邮箱发送结果")
    private String emailSendResult;

    /**
     * 短信发送结果
     */
    @ApiModelProperty(value = "短信发送结果")

    @TableField(value = "note_send_result", condition = LIKE)
    @Excel(name = "短信发送结果")
    private String noteSendResult;

    /**
     * 发送状态 
     * #SendStatus{WAIT:等待发送;SENDING:发送中;NO_SEND:不用发送;SEND_SUCC:发送成功;SEND_FAIL:发送失败;VERIFY_FAIL:发送校验失败;}
     */
    @ApiModelProperty(value = "发送状态")
    @TableField(value = "send_status")
    @Excel(name = "发送状态", replace = {"等待发送_WAIT", "发送中_SENDING", "不用发送_NO_SEND", "发送成功_SEND_SUCC", "发送失败_SEND_FAIL", "发送校验失败_VERIFY_FAIL",  "_null"})
    private SendStatus sendStatus;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @TableField(value = "tenant_id")
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 子系统id
     */
    @ApiModelProperty(value = "子系统id")
    @TableField(value = "subsystem_id")
    @Excel(name = "子系统id")
    private Long subsystemId;

    /**
     * 团队id
     */
    @ApiModelProperty(value = "团队id")
    @TableField(value = "team_id")
    @Excel(name = "团队id")
    private Long teamId;

    /**
     * 排序
     */
    @ApiModelProperty(value = "排序")
    @TableField(value = "sequence")
    @Excel(name = "排序")
    private Integer sequence;

    /**
     * 是否生效(默认1：可用 0:不可用)
     */
    @ApiModelProperty(value = "是否生效(默认1：可用 0:不可用)")
    @TableField(value = "is_enabled")
    @Excel(name = "是否生效(默认1：可用 0:不可用)")
    private Integer isEnabled;

    /**
     * 是否删除(默认0：未删除 1:已删除)
     */
    @ApiModelProperty(value = "是否删除(默认0：未删除 1:已删除)")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除(默认0：未删除 1:已删除)")
    private Integer isDeleted;


    @Builder
    public Msg(Long id, LocalDateTime createTime, Long createdBy, LocalDateTime updateTime, Long updatedBy, 
                    String businessId, String businessType, MsgType msgType, MsgContentType msgContentType, String title, 
                    String content, String author, String mobile, Long userId, String handlerUrl, String handlerParams, 
                    Integer isSendUserAll, Long noteTemplateId, Long emailTemplateId, Long innerMsgTemplateId, Integer isNoteSend, Integer isEmailSend, 
                    Integer isInnerMsgSend, Integer isNoteSendSucc, Integer isEmailSendSucc, Integer isInnerMsgSendSucc, Integer isSendNow, LocalDateTime predictSendTime, 
                    LocalDateTime sendTime, Integer isRead, String emailSendResult, String noteSendResult, SendStatus sendStatus, Long tenantId, 
                    Long projectId, Long subsystemId, Long teamId, Integer sequence, Integer isEnabled, Integer isDeleted) {
        this.id = id;
        this.createTime = createTime;
        this.createdBy = createdBy;
        this.updateTime = updateTime;
        this.updatedBy = updatedBy;
        this.businessId = businessId;
        this.businessType = businessType;
        this.msgType = msgType;
        this.msgContentType = msgContentType;
        this.title = title;
        this.content = content;
        this.author = author;
        this.mobile = mobile;
        this.userId = userId;
        this.handlerUrl = handlerUrl;
        this.handlerParams = handlerParams;
        this.isSendUserAll = isSendUserAll;
        this.noteTemplateId = noteTemplateId;
        this.emailTemplateId = emailTemplateId;
        this.innerMsgTemplateId = innerMsgTemplateId;
        this.isNoteSend = isNoteSend;
        this.isEmailSend = isEmailSend;
        this.isInnerMsgSend = isInnerMsgSend;
        this.isNoteSendSucc = isNoteSendSucc;
        this.isEmailSendSucc = isEmailSendSucc;
        this.isInnerMsgSendSucc = isInnerMsgSendSucc;
        this.isSendNow = isSendNow;
        this.predictSendTime = predictSendTime;
        this.sendTime = sendTime;
        this.isRead = isRead;
        this.emailSendResult = emailSendResult;
        this.noteSendResult = noteSendResult;
        this.sendStatus = sendStatus;
        this.tenantId = tenantId;
        this.projectId = projectId;
        this.subsystemId = subsystemId;
        this.teamId = teamId;
        this.sequence = sequence;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
    }

}
